package com.atguigu.srb.core.controller.api;


import com.atguigu.common.results.R;
import com.atguigu.srb.core.pojo.entity.Lend;
import com.atguigu.srb.core.pojo.query.LendQuery;
import com.atguigu.srb.core.service.LendService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2022-10-24
 */
@RestController
@RequestMapping("/api/core/lend")
public class ApiLendController {
    @Autowired
    LendService lendService;
    @ApiOperation("查询标的详情")
    @GetMapping("lendDetail/{id}")
    public R lendDetail(@PathVariable("id")String id){
        Map<String,Object> map =  lendService.lendDetail(id);
        return R.success().data(map);//使用业务执行返回的map引用设置给R对象的data属性
    }
    @ApiOperation("带条件查询标的列表")
    @GetMapping("list/{pageNum}/{pageSize}")
    public R listLendsPage(LendQuery lendQuery,
                       @PathVariable("pageNum") Integer pageNum,
                       @PathVariable("pageSize")Integer pageSize){//请求参数传参
        Page<Lend> page = lendService.listLendsPage(lendQuery,pageNum,pageSize);
        return R.success().data("page",page);
    }


}

